package com.luo.contentprovider.domain.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * SQLite3数据库创建工具类 完成数据库的创建和删除
 * 
 */
public class DatabaseHelper extends SQLiteOpenHelper
{
	
	private static final String DB_NAME = "noah_know.db";
	private static final int DB_VERSION = 1;
	
	final private Context context;
	
	public DatabaseHelper(Context context)
	{
		super(context, DB_NAME, null, DB_VERSION);
		this.context = context;
	}
	
	// 当数据库被创建的时候，此方法被调用
	@Override
	public void onCreate(SQLiteDatabase db)
	{
		//创建历史表
		PersonSQLTable.createTable(db);
		
	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
	{
		db.execSQL("DROP TABLE IF EXISTS " + PersonSQLTable.TABLE_NAME);
		
		onCreate(db);
	}
}
